﻿Imports System.Drawing.Printing

Public Class frmMesPreferences
    Private szSQL As String
    Private rs As ADODB.Recordset

    Private Sub frmMesPreferences_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        Dim i As Integer
        Dim pkInstalledPrinters As String

        Me.Text = gUserCode & " : Mes préférences"

        ' lister les imprimantes installées
        For i = 0 To PrinterSettings.InstalledPrinters.Count - 1
            pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i)
            CB_BLANC.Items.Add(pkInstalledPrinters)
            CB_ENTETE.Items.Add(pkInstalledPrinters)
        Next

        ' Lire l'utilisateur sélectionné
        szSQL = "SELECT * FROM P_USERS WHERE cd_uti = '" & gUserCode & "'"
        GetRecordset(ctDSN_DEVFAC, szSQL, rs)
        If rs.RecordCount > 0 Then
            CB_BLANC.SelectedIndex = CB_BLANC.FindString(nv(rs.Fields("imp_blanc").Value))
            CB_ENTETE.SelectedIndex = CB_ENTETE.FindString(nv(rs.Fields("imp_entete").Value))
        End If
        rs.Close()

    End Sub

    Private Sub BO_ENREGISTRER_Click(sender As System.Object, e As System.EventArgs) Handles BO_ENREGISTRER.Click

        ' mise à jour de l'utilisateur
        szSQL = "CALL spUpd_USERS_PREFS('" & gUserCode & "','" & ns(CB_BLANC.SelectedItem) & "','" & ns(CB_ENTETE.SelectedItem) & "')"
        ExecQuery(ctDSN_DEVFAC, szSQL)

        Me.Close()

    End Sub
End Class